import base64

import ddddocr

from tools.Func import remove_base64str_title


def get_by_base64(base64_str_info):
    info = ddddocr.base64_to_image(remove_base64str_title(base64_str_info))

    ocr = ddddocr.DdddOcr(show_ad=False)

    return str(ocr.classification(info))


def get_position(slider_image_base64: str, bg_image_base64: str):
    slider_bytes = base64.b64decode(remove_base64str_title(slider_image_base64))  # 移除前缀
    bg_bytes = base64.b64decode(remove_base64str_title(bg_image_base64))
    ocr = ddddocr.DdddOcr(show_ad=False)
    res = ocr.slide_match(slider_bytes, bg_bytes, simple_target=True)

    return  res['target'][0]


# 示例使用

